/*
 * Systemprogrammierung
 * Multiplayer-Quiz
 *
 * Server
 *
 * user.h: Header fÃ¼r die User-Verwaltung
 */

#ifndef USER_H
#define USER_H

#include <stdint.h>

struct UserInfo {

	char *sUsername;			// Nullterminierter Name des Client
	uint8_t iUserID;			// Interne User-ID
	int iSocket;				// Socket
	uint32_t iPunktestand;		// Client Punktestand
	int iQuestionIndex;			// Active Question Index
	int bEndphaseAktiv;			// 0 oder 1
	int iTimeoutRemaining;

	struct UserInfo *ptrNext;

};

void user_InitMutex();
void user_SetMutex();
void user_FreeMutex();
int user_GetUserCount();
int user_UsernameAlreadyTaken(char *sUsername);
int user_AddNewUser(char *sUsername, int iSocketInfo);
struct UserInfo* GetUserByID(uint8_t iUserID);
int user_DeleteUser(uint8_t iUserID);
struct UserInfo** user_GetPointerArray();
struct UserInfo* user_GetUserList();
void user_ResetAllQuestionIndices();
void user_Sort();
void user_DisconnectAllUsers();

#endif
